//
//  NSCalendar+Extension.swift
//  JKWeibo
//
//  Created by albert on 16/5/16.
//  Copyright © 2016年 albert. All rights reserved.
//  NSCalendar分类

import UIKit

extension NSCalendar {
    /** 判断是否为今年 */
    func isDateInThisYear(date: NSDate) -> Bool{
        
        /* 也可以用这个判断
        let thisYearCmps = self.components(NSCalendarUnit.Year, fromDate: NSDate())
        let dateYearCmps = self.components(NSCalendarUnit.Year, fromDate: date)
        */
        
        let thisYear = self.component(NSCalendarUnit.Year, fromDate: NSDate())
        let dateYear = self.component(NSCalendarUnit.Year, fromDate: date)
        return thisYear == dateYear
    }
}
